<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Ruby Summary: Ruby Study Notes - Best Ruby Guide, Ruby Tutorial</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="Ruby Study Notes - Best Ruby Guide, Ruby Tutorial" />
<meta name="keywords" content="free ruby programming guide,ruby guide,free ruby programming course,best ruby guide,ruby tutorials,ruby tutorial,learn ruby,ruby,ruby on rails,ruby rails,ruby learning,ruby tutoring,learning ruby,ruby programming,ruby on rails development,ruby training" />
<meta name="Distribution" content="Global" />
<meta name="author" content="Satish Talim / Original design: Erwin Aligam - ealigam@gmail.com" />
<meta name="copyright" content="Satish Talim 2007 and beyond..." />
<meta name="verify-v1" content="rFu86se+IkbtF+bH8mgJBKwU5HnKaSd8Ghw9umXQOkM=" />
<meta name="robots" content="index,follow" />
<meta http-equiv="Expires" content="0" />
<meta name="revisit-after" content="1 days" />
<link rel="stylesheet" href="/images/NewOrange.css" type="text/css" />
<link rel="icon" type="image/ico" href="/images/favicon.ico" />
<!-- Google +1 button code -->
<link rel="canonical" href="/satishtalim/ruby_summary1.html" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>

<!-- Google Analytics code -->
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-59044-10']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
<!-- Google Analytics code ends -->
</head>

<body>
<!-- wrap starts here -->
<div id="wrap">

    <div id="header">

        <h1 id="logo">Ruby<span class="orange">Learning.github.io</span></h1>
        <h2 id="slogan">Helping Ruby Programmers become Awesome!</h2>

    </div>

    <div id="menu">
        <ul>
            <li><a href="/" title="Home page for rubylearning.github.io">Home</a></li>
            <li><a href="/satishtalim/tutorial.html" title="Get started Learning Ruby here...">Tutorial</a></li>
            <li><a href="/download/downloads.html" title="Download this tutorial as an eBook">Downloads</a></li>
            <li><a href="/other/testimonials.html" title="People around the world who benefited from this site">Testimonials</a></li>
            <li><a href="/other/certification.html" title="Get certified in Ruby">Certification</a></li>
            <li><a href="/satishtalim/ruby_guide.html" title="Ruby Guide, Mentor">Mentor</a></li>
            <li><a href="https://blog.rubylearning.github.io/" title="Ruby blog of Learning Ruby site">Blog</a></li>
            <li><a href="/satishtalim/tutorial.html" title="Online Ruby Course">Online Course</a></li>
            <li><a href="http://ruby-challenge.rubylearning.github.io/" title="Ruby Programming Challenge for Newbies">Challenge</a></li>
            <li><a href="/satishtalim/about.html" title="Information about Satish Talim">About</a></li>
        </ul>
    </div>

    <!-- content-wrap starts here -->
    <div id="content-wrap">


            <div id="main">
                <!-- google_ad_section_start -->
                <div id="main-inner"><a name="TemplateInfo"></a>
                <h1>Ruby Summary</h1>

                <p class="post-footer align-right">
                  <strong>
                    <a href="/satishtalim/variables_and_assignment.html">&lt;Variables and Assignment | </a>
                    <a href="/satishtalim/tutorial.html">TOC | </a>
                    <a href="/satishtalim/scope.html">Scope&gt;</a>
                  </strong>
                </p>

                <ol>
                  <li>We are discussing Ruby 1.9 on the Windows platform. This course is appropriate for Linux/Mac users as well.</li>
                  <li>Ruby is an interpreted language</li>
                  <li>In Ruby, there's always more than one way to solve a given problem.</li>
                  <li>Code layout is pretty much up to you; indentation is not significant (but using two-character indentation will make you friends in the community if you plan on distributing your code).</li>
                  <li>By convention, Ruby source files have the <strong>.rb</strong> file extension. In Microsoft Windows, Ruby source files sometimes end with .rbw, as in myscript.rbw.</li>
                  <li>In Ruby, program execution proceeds in general from top to bottom.</li>
                  <li>Features: Free format, Case sensitive, Two type of comments, Statement delimiters are not required, We have around 41 Keywords.</li>
                  <li>You may be used to thinking that a false value may be represented as a zero, a null string, a null character, or various other things. But in Ruby, all of these *values* are true; in fact, everything is true except the reserved words false and nil.</li>
                  <li>We shall be referring to the documentation <a href="http://www.ruby-doc.org/core-1.9.3/">here</a>.</li>
                  <li><strong>puts</strong> (s in <strong>puts</strong> stands for string; <strong>puts</strong> really means put string) simply writes onto the screen whatever comes after it, but then it also automatically goes to the next line.</li>
                  <li>Parentheses are usually optional with a method call. These calls are all valid:<br />
                      foobar<br />
                      foobar()<br />
                      foobar(a, b, c)<br />
                      foobar a, b, c</li>
                  <li>In Ruby, numbers without decimal points are called integers, and numbers with decimal points are usually called floating-point numbers or, more simply, floats (you must place at least one digit before the decimal point).</li>
                  <li><strong>Note</strong>:  The <strong>Fixnum</strong> and <strong>Bignum</strong> classes represent integers of differing sizes. Both classes descend from <strong>Integer</strong> (and therefore <strong>Numeric</strong>). Ruby is able to deal with extremely large numbers, and unlike many other programming languages, there are no inconvenient limits. Ruby does this with different classes, one called Fixnum (default) that represents easily managed smaller numbers, and another, aptly called <strong>Bignum</strong>, that represents "big" numbers Ruby needs to manage internally. Ruby will handle Bignums and Fixnums for you, and you can perform arithmetic and other operations without any problems. Results might vary depending on your system's architecture, but as these changes are handled entirely by Ruby, there's no need to worry.</li>
                  <li>Some very common Ruby operators:+ addition; - subtraction; * multiplication; / division</li>
                  <li>The increment and decrement operators (++ and --) are not available in Ruby, neither in "pre" nor "post" forms.</li>
                  <li>Anything inside brackets is calculated first (or, more technically, given higher precedence).</li>
                  <li>Observe how the modulus operator (%) works in Ruby.</li>
                  <li>When you do arithmetic with integers, you'll get integer answers.</li>
                  <li>String literals are sequences of characters between single or double quotation marks.</li>
                  <li>In Ruby, strings are mutable. They can expand as needed, without using much time and memory.</li>
                  <li>String concatenation is joining of two strings, using the + operator.</li>
                  <li>The operator &lt;&lt; is used to append to a string</li>
                  <li>Escape sequence is the \ character. Examples: \", \\, \n</li>
                  <li>'' (single quotes) or "" is an empty string.</li>
                  <li>If you get a compilation error like -
                      #&lt;TypeError: cannot convert Fixnum into String&gt;
                      it means that you cannot really add a number to a string, or multiply a string by another string.</li>
                  <li>Constants begin with capital letters. Example PI, Length</li>
                  <li>A local variable springs into existence as soon as the interpreter sees an assignment to that variable. It is a good practice to assign <b>nil</b> to a local variable initially. A runtime error will be generated if the local variable is used without being assigned a value.</li>
                  <li>Use whitespace around the assignment operator:<br />
                      foo = 1<br /><br />
                      not:<br /><br />
                      foo=1</li>
                  <li>Use one initialization per line:<br /><br />
                      level = 0<br />
                      size = 0<br /><br />
                      is preferred over:<br /><br />
                      level = size = 0</li>
                  <li>x, y = y, x will interchange the values of x and y. Parallel assignment is any assignment expression that has more than one lvalue, more than one rvalue, or both. Multiple lvalues and multiple rvalues are separated from each other with commas.</li>
                  <li>Local variables must start with either a lowercase letter or the underscore character (_), and they must consist entirely of letters, numbers, and underscores. Examples: india, _usa, some_var</li>
                  <li>.to_i, .to_f, .to_s are used to convert to an integer, float, string respectively.</li>
                </ol>

                <p style="background-color: #FAFAFA; padding: 5px; margin-top: 20px; font-size: 65%;"><strong>Note</strong>: The Ruby Logo is Copyright (c) 2006, Yukihiro Matsumoto. I have made extensive references to information, related to Ruby, available in the public domain (wikis and the blogs, articles of various <span style="font-weight: bold;" title="Click Gurus on the menu above">Ruby Gurus</span>), my acknowledgment and thanks to all of them. Much of the material on <a href="/">rubylearning.github.io</a> and in the course at <a href="http://rubylearning.org/">rubylearning.org</a> is drawn <strong>primarily</strong> from the <strong>Programming Ruby book</strong>, available from <a href="http://pragprog.com/book/ruby3/programming-ruby-1-9-2-0">The Pragmatic Bookshelf</a>.</p>

                <!-- google_ad_section_end -->
                <p class="post-footer align-right">
                  <strong>
                    <a href="/satishtalim/variables_and_assignment.html">&lt;Variables and Assignment | </a>
                    <a href="/satishtalim/tutorial.html">TOC | </a>
                    <a href="/satishtalim/scope.html">Scope&gt;</a>
                  </strong>
                </p>

            </div>
            <!-- main inner ends here -->
        </div>

            <div id="rightbar">

            </div>

    <!-- content-wrap ends here -->
    </div>

<!-- wrap ends here -->
</div>

<!-- footer starts here -->
<div id="footer">
    <!-- CHANGE THE FOOTER -->
    <p>&copy; 2006-2021 <strong>rubylearning.github.io - A Ruby Tutorial</strong>&nbsp;&nbsp;Page Updated: 5th Jan. 2021 | Design: <a href="mailto:ealigam@gmail.com">Erwin Aligam</a> | Valid: <a href="http://validator.w3.org/check/referer">XHTML</a> | <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">Home</a> | <a href="/privacy.html">Privacy</a> | <a href="/sitemap.html">Sitemap</a></p>
</div>
<!-- footer ends here -->
</body>
</html>
